//
//  ViewController.m
//  study
//
//  Created by codew on 5/31/21.
//

#import "ViewController.h"
#import "WTObject.h"

/**
 ====================================================================================
 
                                使用CFRunLoopSourceRef方式做常驻线程
 
 ====================================================================================
 */


@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    UIButton * btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 400, 120, 200)];
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    btn.backgroundColor = [UIColor redColor];
    [self.view addSubview:btn];
}

/**
 
 */
- (void)runloopTest1
{
    NSLog(@"%s,  线程: %@", __func__, [NSThread currentThread]);

}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self performSelector:@selector(runloopTest1) onThread:[WTObject threadForDispatch] withObject:nil waitUntilDone:NO];
}

- (void)btnClick
{
    NSLog(@"%s,  线程: %@", __func__, [NSThread currentThread]);
    
//    [self performSelector:@selector(odpsadopa)];
}

@end
